package com.compass.mobile.framework.base

import android.view.LayoutInflater
import androidx.viewbinding.ViewBinding
import saveAs
import saveAsUnChecked
import java.lang.reflect.ParameterizedType

/**
 *ViewBinding+ViewModel基类
 */
abstract class BaseVBActivity<VB : ViewBinding> : BaseActivity() {

    lateinit var mBinding: VB


    override fun setContentLayout() {
        val type = javaClass.genericSuperclass
        val vbClass: Class<VB> = type!!.saveAs<ParameterizedType>().actualTypeArguments[0].saveAs()
        val method = vbClass.getDeclaredMethod("inflate", LayoutInflater::class.java)
        mBinding = method.invoke(this, layoutInflater)!!.saveAsUnChecked()
        setContentView(mBinding.root)
    }


    override fun getLayoutResId(): Int = 0



}